//The MIT License
//
//Copyright (c) 2009 nodchip
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.
package tv.dyndns.kishibe.client;

import java.util.HashSet;
import java.util.Set;

public class SharedData {
	private static final SharedData INSTANCE = new SharedData();

	public static SharedData getInstance() {
		return INSTANCE;
	}

	// プレイヤー情報関連
	private int playerId;
	private int playerListIndex;
	private int sessionId;
	private boolean isPlaying = false;
	private boolean isEvent = false;
	private final Set<Integer> userIgnoreUserCode = new HashSet<Integer>();
	private final Set<Integer> serverIgnoreID = new HashSet<Integer>();
	private boolean isThemeMode = false;
	private boolean administoratorMode = false;

	private SharedData() {
	}

	public int getPlayerId() {
		return playerId;
	}

	public void setPlayerId(int playerId) {
		this.playerId = playerId;
	}

	public int getPlayerListIndex() {
		return playerListIndex;
	}

	public void setPlayerListIndex(int playerListIndex) {
		this.playerListIndex = playerListIndex;
	}

	public int getSessionId() {
		return sessionId;
	}

	public void setSessionId(int sessisonId) {
		this.sessionId = sessisonId;
	}

	public void setIsPlaying(boolean playing) {
		isPlaying = playing;
	}

	public boolean getIsPlaying() {
		return isPlaying;
	}

	public void setEvent(boolean isEvent) {
		this.isEvent = isEvent;
	}

	public boolean isEvent() {
		return isEvent;
	}

	public void addUserIgnoreUserCode(int userCode) {
		userIgnoreUserCode.add(userCode);
		Service.Util.getInstance().addIgnoreUserCode(UserData.getInstance().getUserCode(), userCode, Service.NULL_CALLBACK);
	}

	public void removeUserIgnoreUserCode(int userCode) {
		userIgnoreUserCode.remove(userCode);
		Service.Util.getInstance().removeIgnoreUserCode(UserData.getInstance().getUserCode(), userCode, Service.NULL_CALLBACK);
	}

	public void setUserIgnoreUserCodes(Set<Integer> userCodes) {
		userIgnoreUserCode.addAll(userCodes);
	}

	public void setServerIgnoreUserCodes(Set<Integer> userCodes) {
		serverIgnoreID.addAll(userCodes);
	}

	public boolean isIgnoreUserCode(int userCode) {
		return userIgnoreUserCode.contains(userCode) || serverIgnoreID.contains(userCode);
	}

	public void setThemeMode(boolean isThemeMode) {
		this.isThemeMode = isThemeMode;
	}

	public boolean isThemeMode() {
		return isThemeMode;
	}

	public void setAdministoratorMode(boolean administoratorMode) {
		this.administoratorMode = administoratorMode;
	}

	public boolean isAdministoratorMode() {
		return administoratorMode;
	}
}
